home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: WEIRD WEIRD Help Please a.s.a.p.:head pointers
- Date: Sat, 13 Apr 96 13:06:43 GMT
- Organization: none
- Message-ID: <829400803snz@genesis.demon.co.uk>
- References: <4km0vb$o04@badger.wmin.ac.uk>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4km0vb$o04@badger.wmin.ac.uk>
- gsoec@wmin.ac.uk "Idoia Lertxundi" writes:
-
- >Hi C sufferers/lovers,
- >
- >I am working in the C program and I have come accross a weird prob.
- >Rather than sending you code I will explain it in English as I have
- >accurately located the problem.
-
- It is usually a much better idea to post code.
-
- >I have a list which is being created dinamycally and a pointer pointing to
- >the head of the list.
- >
- >ptr=AllocateSpaceforptr();
- >head=ptr;
- >
- > head ptr....ptr
- > | ! ! |
- > {}-{}-{}-NULL
- >
- > 1 2 3 4
- >
- >When I have put data in node number 3 I allocate with a malloc call
- >node number 4 and as the function do not find suitable data to put
- >in number 4 after a for loop I assign it to NULL. i.e.
- >
- > ptr=(FILEMODULE *)NULL;
-
- What is ptr here? If it is a pointer that points to node 4 then assigning
- NULL to it simply loses the reference to node 4, it doesn't affect the
- contents of node 4.
-
- >When I do printfs
-
- What does 'do printfs' mean? What are you printing out and how?
-
- >I see that the list of ptr corresponds to what I was
- >expecting the above picture when I print out the content of the head list
- >which points to the begining of the ptr list the result is unexpected.
- >i.e.
- >
- >head
- > |
- > {}-{}-{}-[] the last node instead of being NULL is not defined.
- >
- > 1 2 3 4
- >
- >By not defined I mean that is a if after malloc there has not been anything
- >put in there although I put the NULL which shows perfectly well in the ptr
- >list. Somehow the head list is not receiving the NULL asigment. WHY??
-
- You're talking about a ptr list as if it is some separate entity. This is all
- very unclear. If you had posted code it would have been trivial to see what
- your mistake was. All we have here is your interpretation of what your
- code does which may itself be wrong.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-